import React, { PropTypes, PureComponent } from 'react';

import IECharts from '../common/IECharts';

export default class AssetRadar extends PureComponent {
  static propTypes = {
    assetRadarData: PropTypes.object.isRequired,
  }

  constructor(props) {
    super(props);
  }
  render() {
    const { assetRadarData } = this.props;
    const returnRateOrig = `${(assetRadarData.portKpis.returnRateOrig * 100)}%`;
    const jensenRatio = `${(assetRadarData.portKpis.jensenRatio * 100).toFixed(2)}%`;
    const radarOptions = {
				// title: {
			  //   	text: '基础雷达图'
			  // 	},
			  	tooltip: {
			  		trigger: 'item',
    formatter: (value, indicator) => (
								`${assetRadarData.portfolioCode}<br/>` +
								`Sharp : ${value.data.value[0]}<br/>` +
								`Treynor : ${value.data.value[1]}<br/>` +
								`信息比率 : ${value.data.value[2]}<br/>` +
								`累计收益率 : ${returnRateOrig}<br/>` +
								`Calmar : ${value.data.value[4]}<br/>` +
								`Jensen : ${jensenRatio}`
							),
			  	},

			  	legend: {
			    	// data: [`${assetRadarData.portfolioCode}`],
			    	padding: [10, 10],
			  	},
				  radar: {
				    // shape: 'circle',
				    indicator: [
							{ name: 'Sharp', max: `${assetRadarData.maxKpis.sharpeRatio}`, min: `${assetRadarData.minKpis.sharpeRatio}` },
				      { name: 'Treynor', max: `${assetRadarData.maxKpis.treynorRatio}`, min: `${assetRadarData.minKpis.treynorRatio}` },
				      { name: '信息比率', max: `${assetRadarData.maxKpis.informationRatio}`, min: `${assetRadarData.minKpis.informationRatio}` },
				      { name: '累计收益率', max: 1, min: 0 },
				      { name: 'Calmar', max: `${assetRadarData.maxKpis.calmarRatio}`, min: `${assetRadarData.minKpis.calmarRatio}` },
				      { name: 'Jensen', max: `${assetRadarData.maxKpis.jensenRatio}`, min: `${assetRadarData.minKpis.jensenRatio}` },
				    ],
				  },
			  	series: [{
				    name: '',
				    type: 'radar',
				    data: [
				      {
				        value: [
				        	`${assetRadarData.portKpis.sharpeRatio}`,
				        	`${assetRadarData.portKpis.treynorRatio}`,
				        	`${assetRadarData.portKpis.informationRatio}`,
				        	`${assetRadarData.portKpis.returnRateOrig}`,
				        	`${assetRadarData.portKpis.calmarRatio}`,
				        	`${assetRadarData.portKpis.jensenRatio}`,
				        	],
				        name: `${assetRadarData.portfolioCode}`,
				      },
				    ],
			  	}],
    };
    return (
      <IECharts option={radarOptions} />
    );
  }
}
